package com.djmw.mouse.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.djmw.mouse.entity.Cv;

public interface CvDao extends PagingAndSortingRepository<Cv, Long>, JpaSpecificationExecutor<Cv> {

    Page<Cv> findByMemberUserId(Long id, Pageable pageRequest);

    List<Cv> findByMemberUserId(Long id);

    @Modifying
    @Query("update Cv cv set cv.status = ?2 where cv.id = ?1")
    void changeStatus(Long id, int status);

    @Query("select cv from Cv cv where cv.memberUser.id = ?1 and cv.status != 10")
    List<Cv> findUndeletedByMemberUserId(Long memberId);

}
